package models;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
public class Assignment extends Model {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8270880530006692155L;

	@Column (length = 32)
	public String title;

	public long deadline;

	@Required (message = "You must choose a course")
	@ManyToOne
	public Course course;

	@OneToMany (mappedBy = "assignment")
	public List<Submission> submissions;

	public String toString() {
		return title + " (" + course.code + ")";
	}

	public static class Object {
		public long id;

		public String title;

		public long deadline;

		public Object (long id, String title, long deadline) {
			this.id = id;
			this.title = title;
			this.deadline = deadline;
		}
	}
}
